package com.zztl.infiniteBand.ui.activity

import android.view.View

import butterknife.OnClick
import com.zztl.infiniteBand.R
import com.zztl.infiniteBand.base.BaseActivity
import com.zztl.infiniteBand.eventbus.PayoutSuccessEvent
import com.zztl.infiniteBand.util.DataFormatUtil
import kotlinx.android.synthetic.main.activity_mention_success.*
import org.greenrobot.eventbus.EventBus

/**
 * @desc
 * @auth ${user}
 * @time 2018/10/13  12:01
 */
class MentionSuccessActivity : BaseActivity() {
    /* @BindView(R.id.iv_status)
     lateinit var iv_status: ImageView
     @BindView(R.id.tv_state)
     lateinit var tv_state: TextView
     @BindView(R.id.tv_money)
     lateinit var tv_money: TextView
     @BindView(R.id.item_address)
     lateinit var item_address: CommonItemView
     @BindView(R.id.item_service_charge)
     lateinit var item_service_charge: CommonItemView
     @BindView(R.id.hint)
     lateinit  var hinit: TextView
     @BindView(R.id.tv_hint)
     lateinit  var tv_hint: TextView*/
    private var mState: String? = null
    private var mMoney: String? = null

    override fun setLayoutId(): Int = R.layout.activity_mention_success


    override fun initBase() {
        mState = intent.getStringExtra("state")?.apply {
            when (this) {
                "0" -> {
                    setHintVisible(false)
                    iv_status.setImageResource(R.mipmap.zhuanzhangcg)
                    tv_state.text = getString(R.string.转出成功)
                }
                "2" -> {
                    setHintVisible(true)
                    iv_status.setImageResource(R.mipmap.zhuanzhangjz)
                    tv_state.text = getString(R.string.转出申请已提交)
                }
            }
        }
        item_address.rightTextStr = intent.getStringExtra("address")
        item_service_charge.rightTextStr = intent.getStringExtra("charge") + "IFR"
        mMoney = intent.getStringExtra("money")
//        val strMoney = mMoney.toString()
        tv_money.text = "-${DataFormatUtil.converTxtPoint4(mMoney!!.toDouble())}"
    }

    @OnClick(R.id.btn_finish)
    fun click() {
        finish()
    }


    private fun setHintVisible(visible: Boolean) {
        hint.visibility = if (visible) View.VISIBLE else View.GONE
        tv_hint.visibility = if (visible) View.VISIBLE else View.GONE
    }

    override fun onDestroy() {
        EventBus.getDefault().post(PayoutSuccessEvent(mMoney!!, mState!!))
        super.onDestroy()
    }
}
